#include "Cube.h"
//---------------------------------------------------------------------------------------------//
Cube::Cube(Graphics &graphics)
	: Entity(graphics)
{
	m_pVertices = new D3DMeshVertex[24];
	
	m_color = 0xff00ff00;

	//m_pVertices[0].SetVertex( 1.0f, 1.0f,-1.0f,m_color, 0.333333f, 0.666667f,-0.666667f);
	//m_pVertices[1].SetVertex(-1.0f, 1.0f,-1.0f,m_color,-0.816497f, 0.408248f,-0.408248f);
	//m_pVertices[2].SetVertex(-1.0f, 1.0f, 1.0f,m_color,-0.333333f, 0.666667f, 0.666667f);
	//m_pVertices[3].SetVertex( 1.0f, 1.0f, 1.0f,m_color, 0.816497f, 0.408248f, 0.408248f);
	//m_pVertices[4].SetVertex( 1.0f,-1.0f,-1.0f,m_color, 0.666667f,-0.666667f,-0.333333f);
	//m_pVertices[5].SetVertex(-1.0f,-1.0f,-1.0f,m_color,-0.408248f,-0.408248f,-0.816497f);
	//m_pVertices[6].SetVertex(-1.0f,-1.0f, 1.0f,m_color,-0.666667f,-0.666667f, 0.333333f);
	//m_pVertices[7].SetVertex( 1.0f,-1.0f, 1.0f,m_color, 0.408248f,-0.408248f, 0.816497f);


	m_pVertices[0].SetVertex(-50.0f, -50.0f,  50.0f, m_color,	0.0f, 0.0f,  1.0f);
    m_pVertices[1].SetVertex( 50.0f, -50.0f,  50.0f, m_color,	0.0f, 0.0f,  1.0f);
    m_pVertices[2].SetVertex(-50.0f,  50.0f,  50.0f, m_color,	0.0f, 0.0f,  1.0f);
    m_pVertices[3].SetVertex( 50.0f,  50.0f,  50.0f, m_color,	0.0f, 0.0f,  1.0f);

    m_pVertices[4].SetVertex(-50.0f, -50.0f, -50.0f, m_color,	0.0f, 0.0f, -1.0f);
    m_pVertices[5].SetVertex(-50.0f,  50.0f, -50.0f, m_color,	0.0f, 0.0f, -1.0f);
    m_pVertices[6].SetVertex( 50.0f, -50.0f, -50.0f, m_color,	0.0f, 0.0f, -1.0f);
    m_pVertices[7].SetVertex( 50.0f,  50.0f, -50.0f, m_color,	0.0f, 0.0f, -1.0f);

    m_pVertices[8].SetVertex(-50.0f,  50.0f, -50.0f, m_color,	0.0f, 1.0f,  0.0f);
    m_pVertices[9].SetVertex(-50.0f,  50.0f,  50.0f, m_color,	0.0f, 1.0f,  0.0f);
    m_pVertices[10].SetVertex( 50.0f,  50.0f, -50.0f, m_color,	0.0f, 1.0f,  0.0f);
    m_pVertices[11].SetVertex( 50.0f,  50.0f,  50.0f, m_color,	0.0f, 1.0f,  0.0f);

    m_pVertices[12].SetVertex(-50.0f, -50.0f, -50.0f, m_color,  0.0f, -1.0f, 0.0f);
    m_pVertices[13].SetVertex( 50.0f, -50.0f, -50.0f, m_color,  0.0f, -1.0f, 0.0f);
    m_pVertices[14].SetVertex(-50.0f, -50.0f,  50.0f, m_color,  0.0f, -1.0f, 0.0f);
    m_pVertices[15].SetVertex( 50.0f, -50.0f,  50.0f, m_color,  0.0f, -1.0f, 0.0f);

    m_pVertices[16].SetVertex( 50.0f, -50.0f, -50.0f, m_color,  1.0f,  0.0f, 0.0f);
    m_pVertices[17].SetVertex( 50.0f,  50.0f, -50.0f, m_color,  1.0f,  0.0f, 0.0f);
    m_pVertices[18].SetVertex( 50.0f, -50.0f,  50.0f, m_color,  1.0f,  0.0f, 0.0f);
    m_pVertices[19].SetVertex( 50.0f,  50.0f,  50.0f, m_color,  1.0f,  0.0f, 0.0f);

    m_pVertices[20].SetVertex(-50.0f, -50.0f, -50.0f, m_color, -1.0f,  0.0f, 0.0f);
	m_pVertices[21].SetVertex(-50.0f, -50.0f,  50.0f, m_color, -1.0f,  0.0f, 0.0f);
    m_pVertices[22].SetVertex(-50.0f,  50.0f, -50.0f, m_color, -1.0f,  0.0f, 0.0f);
    m_pVertices[23].SetVertex(-50.0f,  50.0f,  50.0f, m_color, -1.0f,  0.0f, 0.0f);

	//USHORT indices[] = 
	//{
	//   0,1,2, 0,2,3, 0,4,5,
	//   0,5,1, 1,5,6, 1,6,2,
	//   2,6,7, 2,7,3, 3,7,4,
	//   3,4,0, 4,7,6, 4,6,5
	//};

	USHORT indices[] =
    {
        0, 1, 2,    // side 1
        2, 1, 3,
        
		4, 5, 6,    // side 2
        6, 5, 7,
        
		8, 9, 10,    // side 3
        10, 9, 11,
        
		12, 13, 14,    // side 4
        14, 13, 15,
        
		16, 17, 18,    // side 5
        18, 17, 19,
        
		20, 21, 22,    // side 6
        22, 21, 23,
    };

	m_pIndices = new USHORT[36];
	
	for (int i = 0; i < 36; i++)
	{
		m_pIndices[i] = indices[i];
	}
}
//---------------------------------------------------------------------------------------------//
bool Cube::Draw()
{
	return(this->Entity::Draw(24, m_pVertices, 36, m_pIndices, 12, TRIANGLELIST));
}